package com.theatre.userservice.Controller;

import com.theatre.userservice.model.entity.ScriptComment;
import com.theatre.userservice.model.vo.ScriptCommentVO;
import com.theatre.userservice.model.vo.Result;
import com.theatre.userservice.service.ScriptCommentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/comment")
@Tag(name = "剧本评论接口", description = "提供剧本评论相关接口")
public class ScriptCommentController {

    @Autowired
    private ScriptCommentService commentService;

    @PostMapping("/add")
    @Operation(summary = "添加评论")
    public Result<String> addComment(@RequestBody ScriptComment comment) {
        boolean success = commentService.addComment(comment);
        return success ? Result.success("评论成功") : Result.error("评论失败");
    }

    @GetMapping("/list")
    @Operation(summary = "查看剧本评论")
    public Result<List<ScriptCommentVO>> listComments(@RequestParam Long scriptId) {
        List<ScriptCommentVO> list = commentService.listCommentsByScriptId(scriptId);
        return Result.success(list);
    }
}
